<template>
  <t-dialog :header="`${header}`" :visible.sync="visible" :onClose="closeDialog" :closeOnOverlayClick="false"
    :confirmBtn="null" width="80%" top="5%">
    <div style="height: 65vh;overflow: hidden;overflow-x: scroll;">
      <t-sticky-tool v-if="!hideInfo" :style="{ position: 'absolute', overflow: 'hidden', zIndex: 1000 }"
        :offset="[-50, 60]" @click="createPDF(objId)">
        <t-sticky-item label="导出PDF">
          <template #icon>
            <t-icon name="file-pdf"></t-icon>
          </template>
        </t-sticky-item>
      </t-sticky-tool>
      <base-detail :obj-id="objId"></base-detail>
    </div>
  </t-dialog>
</template>

<script>
import baseDetail from "./base-detail.vue";

export default {
  name: "base-detail-dialog",
  components: {
    baseDetail
  },
  props: {
    objId: [String, Number],
    header: String,
    tabDefaultValue: {
      type: String,
      default: '1'
    }
  },
  data () {
    return {
      visible: true,
      stepValue: this.tabDefaultValue,
    }
  },
  methods: {
    closeDialog () {
      this.$emit("update:visible", false);
    },
    createPDF (id) {
      const instance = this.$loading({
        fullscreen: true,
        attach: 'body',
        preventScrollThrough: false,
      });
      this.$api.kpzh.project.newProjectPDF(id).then(response => {
        window.open(response.data.fullFilePath, '_blank')
        instance.hide();
      }).catch((e) => {
        instance.hide();
        this.$message.error(e.toString());
      });
    },
  }
}
</script>

<style scoped></style>
